package com.ymt.reliable.message.dao.impl;

import com.ymt.reliable.message.dao.TransactionMessageMapper;
import com.ymt.reliable.message.domain.TransactionMessage;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public class TransactionMessageMySqlDBMapperImpl extends BasicDao implements TransactionMessageMapper {
    private static final String INSERT = "com.ymt.reliable.message.dao.TransactionMessageMapper.insert";
    private static final String DELETEBYMESSAGEID = "com.ymt.reliable.message.dao.TransactionMessageMapper.deleteByMessageId";
    private static final String GET = "com.ymt.reliable.message.dao.TransactionMessageMapper.get";
    private static final String UPDATE = "com.ymt.reliable.message.dao.TransactionMessageMapper.update";
    private static final String QUERYRETRYLIST = "com.ymt.reliable.message.dao.TransactionMessageMapper.queryRetryList";
    private static final String QUERYCONFIRMLIST = "com.ymt.reliable.message.dao.TransactionMessageMapper.queryConfirmList";

    @Override
    public Long insert(TransactionMessage message) {
        this.sqlSession.insert(INSERT, message);
        return message.getId();
    }

    @Override
    public Integer deleteByMessageId(String messageId) {
        return this.sqlSession.delete(DELETEBYMESSAGEID, messageId);
    }

    @Override
    public TransactionMessage get(String messageId) {
        return this.sqlSession.selectOne(GET, messageId);
    }

    @Override
    public Integer update(TransactionMessage message) {
        return this.sqlSession.update(UPDATE, message);
    }

    @Override
    public List<TransactionMessage> queryRetryList(Map<String, Object> params) {
        return this.sqlSession.selectList(QUERYRETRYLIST, params);
    }

    @Override
    public List<TransactionMessage> queryConfirmList(Map<String, Object> params) {
        return this.sqlSession.selectList(QUERYCONFIRMLIST, params);
    }
}
